﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Pansoft.HIME.Base.Interfaces;
using Pansoft.HIME.Base.Interfaces.Repositories;
using Pansoft.HIME.Base.ViewModels.Statistics;
using Pansoft.HIME.Repository;

namespace Pansoft.HIME.Controllers.Api.Statistics
{
    /// <summary>
    /// 明细数据、当前等候、当前服务报表均使用该控制器
    /// </summary>
    public class TransactionController : ApiController
    {
        private readonly ITransactionRepository _Repository;
        public TransactionController()
        {
            _Repository = RepositoriesFactory.Instance.TransactionRepository;
        }

        public BatchDataViewModel<TransactionViewModel> Post(QueryParam queryParam)
        {
            int totalcount;
            var result = _Repository.Get(queryParam, out totalcount);
            if (totalcount == 0)
            {
                return new BatchDataViewModel<TransactionViewModel>(new List<TransactionViewModel>(), 0);
            }
            return new BatchDataViewModel<TransactionViewModel>(result, totalcount);
        } 
    }
}
